Nginx config with try_files and rewrite : precedence?

Posted by Penegal on Server Fault See other posts from Server Fault or by Penegal
Published on 2014-06-06T07:48:27Z Indexed on 2014/06/06 9:27 UTC
Read the original article Hit count: 162

Filed under:
|
|

Good morning, everybody.

Firstly, this question may have been already asked, but I searched ServerFault during about 15 minutes without finding it, so, if it was already asked, please accept my apologies.

I'm trying to rationalize my Nginx server config, but I have a rather dumb question that I couldn't solve, even with extensive Web search, except if I totally f*cked my search. Here is the question : is try_files parsed before or after rewrite ? Asked differently, Do I have to put try_files after all rewrite directives, or is Nginx config parser smart enough to evaluate try_files after all relevant rewrite directives ?

The link with the config rationalization is that the answer to this question will change the organisation of the config, ie if config file order of try_files and rewrite changes the config behaviour, it will force me to disperse my includes, some of them containing try_files and other ones containing rewrite, because I also have rewrite directly in nginx.conf.

Hoping you can help me,

Regards.

© Server Fault or respective owner

Related posts about nginx

Related posts about configuration